package com.cskaoyan.order.biz.handler;

import com.cskaoyan.mall.commons.exception.BizException;
import com.cskaoyan.order.biz.context.CreateOrderContext;
import com.cskaoyan.order.biz.context.TransHandlerContext;
import com.cskaoyan.order.constant.OrderRetCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Collection;

@Slf4j
@Component
public class ValidateHandler extends AbstractTransHandler {



    @Override
    public boolean isAsync() {
        return false;
    }

    @Override
    public boolean handle(TransHandlerContext context) {
        CreateOrderContext createOrderContext = (CreateOrderContext) context;

        if (createOrderContext.getUserId() == null || createOrderContext.getAddressId() == null) {
            throw new BizException(OrderRetCode.REQUISITE_PARAMETER_NOT_EXIST.getCode(),
                    OrderRetCode.REQUISITE_PARAMETER_NOT_EXIST.getMessage());
        }

        return true;
    }
}
